package com.family.web.controller.pedigree;


import com.family.common.core.controller.BaseController;
import com.family.common.core.domain.AjaxResult;
import com.family.common.core.page.TableDataInfo;
import com.family.pedigree.domain.FamilyLeader;
import com.family.pedigree.service.IFamilyLeaderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 领导简介表 前端控制器
 * </p>
 *
 * @author forever
 * @since 2025-01-13
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/family/leader")
public class FamilyLeaderController extends BaseController {

    private final IFamilyLeaderService familyLeaderService;

    @PostMapping
    public AjaxResult add(@Validated @RequestBody FamilyLeader familyLeader) {
        familyLeaderService.add(familyLeader);
        return AjaxResult.success();
    }

    @PutMapping
    public AjaxResult update(@Validated @RequestBody FamilyLeader familyLeader) {
        familyLeaderService.updateById(familyLeader);
        return AjaxResult.success();
    }

    @GetMapping("list")
    public TableDataInfo list(FamilyLeader familyLeader) {
        startPage();
        return getDataTable(familyLeaderService.selectList(familyLeader));
    }

    @DeleteMapping("{leaderId}")
    public AjaxResult delById(@PathVariable Long leaderId) {
        return AjaxResult.success(familyLeaderService.removeById(leaderId));
    }


}
